﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Xml.Linq;
using AspNet.StarterKits.Classifieds.BusinessLogicLayer;
using AspNet.StarterKits.Classifieds.Web;

public partial class ajaxSearch : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        Response.Expires = -1;
        //required to keep the page from being cached on the client's browser        
        Response.ContentType = "text/plain";
        string q = Request.QueryString["q"];
        if (q != null)
        {
            if (q.Length > 2)
            {
                //Response.End();
                AdsDataComponent.AdsDataTable ads = AdsDB.GetActiveAdsByQuery(50, 0, 0, -1, q, "", 0, 0, -1, false);
                foreach (AdsDataComponent.AdsRow row in ads)
                {
                    Response.Write(row["title"].ToString().Replace("£","") + "\n");
                }
            }
            else
            {
                Response.Write(" ");
            }
        }
        else
            Response.Write(" ");

       Response.End();
    }
}
